load("@rules_python//python:defs.bzl", "py_binary", "py_library")

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "tf_dependency",
    tags = ["local"],
    deps = [
        "@local_config_tf//:libtensorflow_framework",
        "@local_config_tf//:tf_header_lib",
    ],
)

cc_binary(
    name = "_custom_ops.so",
    srcs = [
        "custom_ops.cc",
    ],
    copts = [
        "-pthread",
        "-std=c++11",
        "-D_GLIBCXX_USE_CXX11_ABI=0",
    ],
    linkshared = 1,
    deps = [
        ":tf_dependency",
    ],
)

py_library(
    name = "custom_ops_py",
    srcs = [
        "custom_ops.py",
    ],
    data = [
        ":_custom_ops.so",
        "@rules_python//python/runfiles",
    ],
    srcs_version = "PY3",
)

py_library(
    name = "model",
    srcs = ["model.py"],
    srcs_version = "PY3",
    deps = [
        ":custom_ops_py",
        ":encoding",
        ":env",
    ],
)

py_library(
    name = "bert_client",
    srcs = [
        "bert_client.py",
    ],
    deps = [
    ],
)

py_library(
    name = "word2vec_client",
    srcs = ["word2vec_client.py"],
    deps = [
    ],
)

py_library(
    name = "encoding",
    srcs = ["encoding.py"],
    deps = [
    ],
)

py_library(
    name = "env",
    srcs = ["env.py"],
    deps = [
        ":encoding",
    ],
)

filegroup(
    name = "contrack_people_names",
    srcs = [
        "data/female_names.txt",
        "data/male_names.txt",
    ],
)

py_library(
    name = "signals",
    srcs = ["signals.py"],
    data = [
        ":contrack_people_names",
    ],
    deps = [
        "@bazel_tools//tools/python/runfiles",
    ],
)

py_library(
    name = "data",
    srcs = ["data.py"],
    deps = [
        ":encoding",
        ":env",
    ],
)

py_library(
    name = "train_lib",
    srcs = ["train.py"],
    deps = [
        ":data",
        ":encoding",
        ":env",
        ":model",
    ],
)

py_binary(
    name = "train",
    srcs = ["train.py"],
    srcs_version = "PY3",
    deps = [
        ":train_lib",
    ],
)

py_binary(
    name = "preprocess",
    srcs = [
        "preprocess.py",
    ],
    srcs_version = "PY3",
    deps = [
        ":bert_client",
        ":encoding",
        ":signals",
        ":word2vec_client",
    ],
)

py_binary(
    name = "predict",
    srcs = ["predict.py"],
    srcs_version = "PY3",
    deps = [
        ":data",
        ":encoding",
        ":env",
        ":model",
        ":signals",
    ],
)
